import { createApp } from 'vue'
import App from './App.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import router from './router'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'


// // 完整屏蔽 ResizeObserver 相关非致命错误
// const ignoreResizeObserverErrors = (event) => {
//   const msg = event.message || event.reason?.message || String(event.reason || '')
//   if (
//     msg.includes('ResizeObserver loop limit exceeded') ||
//     msg.includes('ResizeObserver loop completed with undelivered notifications.')
//   ) {
//     event.stopImmediatePropagation()
//     event.preventDefault()
//     return true
//   }
//   return false
// }

// // 监听同步 error 事件
// window.addEventListener('error', ignoreResizeObserverErrors, true)
// // 监听异步 Promise 错误
// window.addEventListener('unhandledrejection', ignoreResizeObserverErrors, true)



const app = createApp(App)

// ✅ 2️⃣ 全局注册图标组件
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// ✅ 3️⃣ 挂载
app.use(ElementPlus, {
  locale: zhCn,
})
app.use(router)
app.mount('#app')
